import { defineStore } from 'pinia';

export const useStore = defineStore('apkbackend', {
  state: () => ({
    menuinfo: null,
    activemenu: "homepage",
    userinfo: null,
    storeinfo: null,
    clubdataTimestamp: "",
    clubdataCityName: "",
    tablemessage: [],
    yuyueingOrder: {
      table: [],
      zhujiao: []
    },
    playingorder: {
      table: [],
      zhujiao: []
    },
    notpayorder: {
      table: [],
      zhujiao: []
    }
  }),
  actions: {
    setMenuinfo(menuinfo) {
      this.menuinfo = menuinfo;
    },
    setActivemenu(activemenu) {
      this.activemenu = activemenu;
    },
    setUserinfo(userinfo) {
      this.userinfo = userinfo
    },
    setStoreinfo(storeinfo) {
      this.storeinfo = storeinfo
    },
    setStoreTimestamp(timestamp) {
      this.clubdataTimestamp = timestamp
    },
    setStoreCityName(clubdataCityName) {
      this.clubdataCityName = clubdataCityName
    },
    setTableMessage(tablemessage) {
      this.tablemessage = tablemessage
    },
    setYuyueingOrder(yuyueingOrder) {
      this.yuyueingOrder = yuyueingOrder
    },
    setPlayingOrder(playingorder) {
      this.playingorder = playingorder
    },
    setNotPayOrder(notpayorder) {
      this.notpayorder = notpayorder
    }
  },
  getters: {
    getMenuStoreinfo() {
      return this.menuinfo;
    },
    getActivemenu() {
      return this.activemenu;
    },
    getUserStoreinfo() {
      return this.userinfo;
    },
    getStoreinfo() {
      return this.storeinfo;
    },
    getStoreTimestamp() {
      return this.clubdataTimestamp
    },
    getStoreCityName() {
      return this.clubdataCityName
    },
    getTableMessage() {
      return this.tablemessage
    },
    getYuyueingOrder() {
      return this.yuyueingOrder
    },
    getPlayingOrder() {
      return this.playingorder
    },
    getNotPayOrder() {
      return this.notpayorder
    },
  },
  persist: {
    enabled: true, // 开启数据缓存
    strategies: [
      {
        key: 'menuinfo',
        storage: localStorage,
        paths: ['menuinfo']
      },
      {
        key: 'userinfo',
        storage: localStorage,
        paths: ['userinfo']
      },
      {
        key: 'storeinfo',
        storage: localStorage,
        paths: ['storeinfo']
      },
      {
        key: 'clubdataCityName',
        storage: localStorage,
        paths: ['clubdataCityName']
      },
      {
        key: 'tablemessage',
        storage: localStorage,
        paths: ['tablemessage']
      },
    ]
  }
});
